package com.example.hun_food_sharing_system.food_list;

import android.os.Bundle;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.example.hun_food_sharing_system.R;
import com.example.hun_food_sharing_system.bean.FoodBean;
import com.example.hun_food_sharing_system.bean.FoodUtils;

import java.util.ArrayList;
import java.util.List;

public class InfoListActivity extends AppCompatActivity {
    EditText searchEt;
    ImageView searchIv,flushIv;
    ListView showLv;
    //    ListView内部数据源
    List<FoodBean>mDatas;
    List<FoodBean> allFoodList;
    private InfoListAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_info_list);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
        //        查找控件
        initView();
//        2.找到ListView对应的数据源
        mDatas = new ArrayList<>();
        allFoodList = FoodUtils.getAllFoodList();
        mDatas.addAll(allFoodList);
//        3.创建适配器  BaseAdapter的子类
        adapter = new InfoListAdapter(this, mDatas);
        showLv.setAdapter(adapter); //4.设置适配器
//        设置单向点击监听功能
        setListener();
    }


}